﻿using System;
using System.Collections.Generic;

namespace ParserGenerator.Collections
{
    public static class Dictionary
    {
        public static Dictionary<TKey, TValue> GetEmpty<TKey, TValue>()
        {
            return new Dictionary<TKey, TValue>();
        }

        public static Dictionary<TKey, TValue> New<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>> collection)
        {
            if (collection == null)
                throw new ArgumentNullException(nameof(collection));
            var dict = new Dictionary<TKey, TValue>();
            foreach (var t in collection)
                dict[t.Key] = t.Value;
            return dict;
        }

        public static Dictionary<TKey, TValue> Create<TKey, TValue>(params KeyValuePair<TKey, TValue>[] items)
        {
            if (items == null)
                throw new ArgumentNullException(nameof(items));
            return New(items);
        }
    }
}
